home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8304 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  59 lines

  1. Path: gollum.kingston.net!usenet
  2. From: girard@haventree.com (Eugene Girard)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: READ THIS!!!!!!!!!!!
  5. Date: Fri, 16 Feb 1996 17:33:27 GMT
  6. Organization: HavenTree Software, Limited
  7. Message-ID: <4g2im5$sv3@gollum.kingston.net>
  8. References: <4em5fs$a86@ixnews4.ix.netcom.com>
  9. NNTP-Posting-Host: buddy.haventree.com
  10. X-Newsreader: Forte Free Agent v0.55
  11.  
  12. jeremyx@ix.netcom.com(Jeremy Johnston ) wrote:
  13.  
  14.  
  15. >  ok....now that I have your attention i need some help.
  16. >I can't get the following command to work & the compiler says that the
  17. >constant has too many characters.
  18.  
  19. >  char dos;
  20. >    if(dos=='dir')
  21. >    goto b;
  22.  
  23. >How can i do this to get it to work?
  24.  
  25. Try:
  26. char *dos;
  27. ...
  28. if (strcmp( dos, "dir") == 0)
  29.   goto b;
  30.  
  31. A few notes:
  32. 1) You don't need a goto here.  Try to stick the appropriate code
  33. immediately after the if statement.  (The rule is: Avoid GOTO's unless
  34. you have a darn good reason to use them.)
  35. 2) You can't compare literal strings directly (dos == "dir"), since
  36. this would test to see if the pointers were pointing to the same
  37. address.  Instead, use a string comparison function.
  38. 3) Strings are enclosed in double quotes, not single.  Single quotes 
  39. are used to define character constants.  The real difference is that 
  40. string constants are null-terminated strings, while char constants 
  41. are just the char.
  42.  
  43. > please help,I know you can.
  44. Just one more comment.  People will be more willing to help if you
  45. include a reasonable subject for your article.  "READ THIS!!!!!!!!" is
  46. not very informative, and probably not the most polite way of asking
  47. for help from a group of strangers.
  48.  
  49.  
  50.  
  51.  
  52.  
  53. --
  54. Eugene Girard, Programmer, HavenTree Software Limited
  55. HavenTree makes EasyFlow (Windows, DOS, MAC) and Nodemap (Windows, DOS)
  56. For more information, check out http://www.haventree.com
  57.  
  58.